import time
def buble(nums):
    q = True
    while q:
        q = False
        for i in range(len(nums)-1):
            if nums[i] > nums[i+1]:
                nums[i], nums[i+1] = nums[i+1], nums[i]
                q = True
with open('m1_sorted.txt') as f:
    s1 = f.readlines()
a1 = [int(i1) for i1 in s1]
with open('m2_reverse.txt') as f:
    s2 = f.readlines()
a2 = [int(i2) for i2 in s2]
with open('m3_shuffle.txt') as f:
    s3 = f.readlines()
a3 = [int(i3) for i3 in s3]
start1 = time.time()
buble(a1)
end1 = time.time()
print('m1_sorted.txt', (end1 - start1)*1000)
start2 = time.time()
buble(a2)
end2 = time.time()
print('m2_reverse.txt', (end2 - start2)*1000)
start3 = time.time()
buble(a3)
end3 = time.time()
print('m3_shuffle.txt', (end3 - start3)*1000)
                       
